#ifndef __LOGIN_H__
#define __LOGIN_H__
#include "lvgl/lvgl.h"

typedef struct user
{
    char userID[20];   // 用户ID
    char username[20]; // 用户名
    char password[20]; // 密码
    char phone[20];    // 手机号
} user_t, *user_p;

typedef struct user_Node
{
    user_p data;
    struct user_Node * prev;
    struct user_Node * next;
} user_Node_t, *user_Node_p;

extern user_Node_p user_headNode;
extern user_Node_p user_currNode;
extern int user_index;
extern lv_obj_t * kb;
extern int kb_open;

extern lv_obj_t * login_error;
extern lv_obj_t * error_label;
extern lv_timer_t * error_timer;

void login_init(lv_obj_t * parent);
void ta_event_cb(lv_event_t * e);
void overlay_event_cb(lv_event_t * e);

user_Node_p user_create();
user_Node_p find_userNode(user_Node_p headNode, char * userID);
void save_file_user();
user_Node_p load_file_user();

int login(user_Node_p headNode, char * userID, char * password);
int register_user(user_Node_p headNode, char * userID, char * password);

void show_error_window(const char * error_message, int mode);
void hide_error_window(lv_event_t * e); // 隐藏错误窗口
void create_error_window(int mode);

#endif